package com.oddfar.campus.business.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.oddfar.campus.business.domain.Wzxx;
import com.oddfar.campus.business.domain.Wzxx;
import com.oddfar.campus.common.core.BaseMapperX;
import com.oddfar.campus.common.core.LambdaQueryWrapperX;
import com.oddfar.campus.common.domain.PageResult;
import org.apache.ibatis.annotations.*;
import org.springframework.security.core.parameters.P;
import org.springframework.web.multipart.MultipartFile;

public interface WzxxMapper extends BaseMapperX<Wzxx> {


    default PageResult<Wzxx> selectPage(Wzxx wzxx) {
        return selectPage(new LambdaQueryWrapperX<Wzxx>()
                .eqIfPresent(Wzxx::getPhonenumber, wzxx.getPhonenumber())
                .eqIfPresent(Wzxx::getClpzh, wzxx.getClpzh())
                .eqIfPresent(Wzxx::getCllxDm, wzxx.getCllxDm())
                .eqIfPresent(Wzxx::getClbz, wzxx.getClbz())
                .orderByAsc(Wzxx::getWzsj)
        );
    }
    default PageResult<Wzxx> selectclPage(Wzxx wzxx, Long phonenumber) {
        return selectPage(new LambdaQueryWrapperX<Wzxx>()
                .eq(Wzxx::getPhonenumber, wzxx.getPhonenumber())
                .eqIfPresent(Wzxx::getClpzh, wzxx.getClpzh())
                .eqIfPresent(Wzxx::getCllxDm, wzxx.getCllxDm())
                .eqIfPresent(Wzxx::getClbz, wzxx.getClbz())
                .eq(Wzxx::getClbz, "0")
                .orderByAsc(Wzxx::getWzsj)
        );
    }

    default PageResult<Wzxx> selectPage(Wzxx wzxx, Long phonenumber) {

        return selectPage(new LambdaQueryWrapperX<Wzxx>()
                .eq(Wzxx::getPhonenumber, phonenumber)
                .eqIfPresent(Wzxx::getClpzh, wzxx.getClpzh())
                .eqIfPresent(Wzxx::getCllxDm, wzxx.getCllxDm())
                .orderByAsc(Wzxx::getWzsj)
        );

    }

    @Delete("DELETE FROM dj_wzxx WHERE djxh in (#{djxh})")
    int deleteWzxx(Long djxh);

    @Select("SELECT djxh FROM dj_clqkxx WHERE phonenumber = #{phonenumber} AND clpzh = #{clpzh}")
    long selectDjxhByMobile(@Param("phonenumber") String phonenumber, @Param("clpzh") String clpzh);

    @Insert("INSERT INTO pic_base (pic) VALUES (#{pic})")
    int updateUserAvatar(@Param("pic") String pic);


    @Select("SELECT phonenumber from oddfar_campus.dj_clqkxx where user_id = #{userId} LIMIT 1")
    Long selectdjxhByuserid(Long userId);
}